package com.cardone.platform.authority.service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;


import lombok.Getter;


import lombok.Setter;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;

import com.cardone.common.dto.PaginationDto;
import com.cardone.common.cache.Caches;
import com.cardone.context.Attributes;
import com.cardone.context.ContextHolder;
import com.cardone.common.util.EntityUtils;
import com.cardone.platform.authority.dao.PermissionDao;
import com.cardone.platform.authority.dto.PermissionDto;

/**
 * 许可服务
 *
 * @author yaohaitao
 * 
 */
@Getter 
@Setter
@Transactional(readOnly = true)
public class PermissionDefaultService implements PermissionService {
	@Override
	@Transactional
	public <P> P saveByIdOrCode(Class<P> mappedClass, PermissionDto savePermission) {
		return ContextHolder.getBean(PermissionDao.class).saveByIdOrCode(mappedClass, savePermission);
	}
	
	@Override
	@Transactional
	public PermissionDto saveByIdOrCode(PermissionDto savePermission) {
		return ContextHolder.getBean(PermissionDao.class).saveByIdOrCode(PermissionDto.class, savePermission);
	}
	
	@Override
	public <P> P findByCodeOrId(Class<P> mappedClass, PermissionDto findPermission) {
		return ContextHolder.getBean(PermissionDao.class).findByCodeOrId(mappedClass, findPermission);
	}
	
	@Override
	public Integer readByCodeNqIdForCount(PermissionDto readPermission) {
		return ContextHolder.getBean(PermissionDao.class).readByCodeNqIdForCount(readPermission);
	}
	
	@Override
	@Transactional
	public int insertByCode(PermissionDto insertPermission) {
		return ContextHolder.getBean(PermissionDao.class).insertByCode(insertPermission);
	}
	
	@Override
	@Transactional
	public int updateByCode(PermissionDto updatePermission) {
		return ContextHolder.getBean(PermissionDao.class).updateByCode(updatePermission);
	}

	@Override
	@Transactional
	public int deleteByIds(PermissionDto deletePermission) {
		return ContextHolder.getBean(PermissionDao.class).deleteByIds(deletePermission);
	}

	@Override
	public <P> P findById(Class<P> mappedClass, PermissionDto findPermission) {
		return ContextHolder.getBean(PermissionDao.class).findById(mappedClass, findPermission);
	}

	@Override
	public <P> List<P> findListByLikeCode(Class<P> mappedClass, PermissionDto findListPermission) {
		return ContextHolder.getBean(PermissionDao.class).findListByLikeCode(mappedClass, findListPermission);
	}

	@Override
	public <P> List<P> findList(Class<P> mappedClass) {
		return ContextHolder.getBean(PermissionDao.class).findList(mappedClass);
	}

	@Override
	public <P> PaginationDto<P> paginationByLikeCode(Class<P> mappedClass, PermissionDto paginationPermission) {
		return ContextHolder.getBean(PermissionDao.class).paginationByLikeCode(mappedClass, paginationPermission);
	}
}